package TestThread4;

import org.junit.jupiter.api.Test;

import java.util.UUID;
import java.util.Vector;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @Author Mr.Wen
 * @Version 1.0
 */
public class Test1 implements Callable {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> System.out.println("run"), "hello runnable");
        System.out.println(thread.getName());
        thread.start();
    }

    @Override
    public Object call() throws Exception {
        Vector<Object> vector = new Vector<>();
        for (int i = 0; i < 100; i++) {
            vector.add(UUID.randomUUID().toString().substring(0, 8));
        }
        return vector;
    }

    @Test
    void res() throws Exception {
        Test1 test1 = new Test1();
        FutureTask futureTask = new FutureTask<>(test1);
        Thread thread = new Thread(futureTask);
        thread.start();
        Object call = test1.call();
        System.out.println("call = " + call);
    }

    @Test
    void test2() {
        for (int i = 0; i < 30; i++) {
            Thread thread = new Thread(() -> System.out.println(Thread.currentThread().getName()));
            thread.start();
        }
    }
}
